<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'occupancy-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php // echo $form->labelEx($model,'idTenant'); ?>
		<?php echo $form->hiddenField($model,'idTenant'); ?>
		<?php //echo $form->error($model,'idTenant'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'Rental Property'); ?>
        <?php echo $form->dropDownList($model,'idRentalProperty', CHtml::listData( Rentalproperty::model()->findAll(),
                 'id',      // values
                 'AddressOne',    // captions
                 'idManagement0.CompanyName'), array('prompt'=>' Choose ', 'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('rentalunit/dynamicRentalunits'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#Occupancy_idRentalUnit', //selector to update
//'data'=>'js:javascript statement' 
//leave out the data key to pass all form values through
))); ?>
       
       	<?php // echo $form->textField($model,'idRentalProperty'); ?>
		<?php echo $form->error($model,'idRentalProperty'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'Rental Unit Number'); ?>
		<?php //echo CHtml::dropDownList('Occupancy_idRentalunit','', array());
		
		//echo $form->textField($model,'idRentalUnit'); 
		if($model->isNewRecord)
			echo $form->dropDownList($model,'idRentalUnit',array('prompt'=>'Choose')); 
		else 
		echo $form->dropDownList($model,'idRentalUnit',array( $model->idRentalUnit => $model->idRentalUnit0->UnitNumber),array('prompt'=>'Choose'));
		?>
		<?php echo $form->error($model,'idRentalUnit'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'MoveInDate'); ?>
		<?php //echo $form->textField($model,'MoveInDate'); 
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    
	'model'=>$model,
    'attribute'=>'MoveInDate',
    // additional javascript options for the date picker plugin
    'options'=>array(
		'dateFormat'=>'yy-mm-dd',
        'showAnim'=>'fold',
    ),
    'htmlOptions'=>array(
        
    ),
));?>
		<?php echo $form->error($model,'MoveInDate'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'SoftwareTenantNumber'); ?>
		<?php echo $form->textField($model,'SoftwareTenantNumber',array('size'=>15,'maxlength'=>15)); ?>
		<?php echo $form->error($model,'SoftwareTenantNumber'); ?>
	</div>

	<div class="row">
		<?php 
		$checked=0;
		if(!$model->isNewRecord) {
			$iscrruent=Tenantreportedcurrentaddress::model()->find('idTenant=:t_id', array(':t_id'=>$model->idTenant));
				
		if($iscrruent->idRentalProperty == $model->idRentalProperty && $iscrruent->idRentalUnit == $model->idRentalUnit && $iscrruent->idTenant == $model->idTenant)
			$checked=1;
		}
		echo CHtml::label('Currently Living Here ?', 'isCurrentAdd');
		echo CHtml::CheckBox('isCurrentAdd',$checked);
		?> 
		
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'MoveOutDate'); ?>
		<?php //echo $form->textField($model,'MoveOutDate'); 
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    
	'model'=>$model,
    'attribute'=>'MoveOutDate',
    // additional javascript options for the date picker plugin
    'options'=>array(
		'dateFormat'=>'yy-mm-dd',
        'showAnim'=>'fold',
    ),
    'htmlOptions'=>array(
        
    ),
));
		
		?>
		<?php echo $form->error($model,'MoveOutDate'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'LeaseEndDate'); ?>
		<?php //echo $form->textField($model,'LeaseEndDate');
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    
	'model'=>$model,
    'attribute'=>'LeaseEndDate',
    // additional javascript options for the date picker plugin
    'options'=>array(
		'dateFormat'=>'yy-mm-dd',
        'showAnim'=>'fold',
    ),
    'htmlOptions'=>array(
        
    ),
));
		 ?>
		<?php echo $form->error($model,'LeaseEndDate'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'Occupancycol'); ?>
		<?php //echo $form->textField($model,'Occupancycol'); 
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    
	'model'=>$model,
    'attribute'=>'Occupancycol',
    // additional javascript options for the date picker plugin
    'options'=>array(
		'dateFormat'=>'yy-mm-dd',
        'showAnim'=>'fold',
    ),
    'htmlOptions'=>array(
        
    ),
));
		
		?>
		<?php echo $form->error($model,'Occupancycol'); ?>
	</div>

	<div class="row compactRadioGroup">
		<?php echo $form->labelEx($model,'MonthToMonthTenancy'); ?><br />
		<?php //echo $form->textField($model,'MonthToMonthTenancy',array('size'=>1,'maxlength'=>1)); ?>
        <?php echo $form->radioButtonList($model,'MonthToMonthTenancy',array('1'=>'Yes','0'=>'No'), array( 'separator' => "&nbsp; &nbsp;" )); ?>
		<?php echo $form->error($model,'MonthToMonthTenancy'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
</div>
<?php $this->endWidget(); 